import { h } from 'vue'
import { NIcon } from 'naive-ui'

// 渲染图标
export function renderIcon(icon: any) {
    return () => h(NIcon, null, { default: () => h(icon) })
}

// 随机字符串
export function randomString(length?: number): string {
    length = length || 32
    let t = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
    let str = ''
    for (let i = 0; i < length; i++) str += t.charAt(Math.floor(Math.random() * t.length))
    return str
}

// 反转字符串
export function reverseString(str: string): string {
    return str.split('').reverse().join('')
}
